﻿using HttpClientStudy.Core.Utilities;

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace HttpClientStudy.WebClient.Controllers
{
    /// <summary>
    /// 管理API
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ManagerController : ControllerBase
    {
        private readonly ILogger<ManagerController> _logger;
        
        /// <summary>
        /// 构造
        /// </summary>
        /// <param name="logger"></param>
        public ManagerController(ILogger<ManagerController> logger) 
        {
            _logger = logger;
        }

        /// <summary>
        /// 启动WebApi项目进程
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult StartWebApi()
        {
            AppUtility.StartWebApiProject();

            return Ok("启动成功");
        }

        /// <summary>
        /// 退出WebApi项目进程
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult ExitWebApi()
        {
            AppUtility.ExitWebApiProject();

            return Ok("进程已退出");
        }
    }
}
